#pragma once

#include "IContractChecker.h"
#include "SimpleCriticalSection.h"

namespace RoomFW {

//
// Class:	ContractChecker
//
// Description:	Base Contract Checker implementation.
//
// Author:	Andrew Sage
//
class ContractChecker : public IContractChecker
{
public:

	//
	// Method:	ContractChecker
	//
	// Description:	Constructor
	//
	// Parameters:
	//
	//	conjugate - Flag if this contract checker represents a conjugated port.
	//
	ContractChecker(bool conjugate, bool isLogged = true);

	//
	// Method:	~ContractChecker
	//
	// Description:	Virtual destructor to ensure derived class destructors called.
	//
	virtual ~ContractChecker() {};

	//
	// Base class overrides.
	//
	virtual bool isConjugate() const;
	virtual bool getIsLogged() const;
	virtual void setIsLogged(bool isLogged) const; //This shouldn't be const, but all our access to contract checkers
												   //is const and we need to be able to change this flag...

private:

	//
	// Flag if this contract checker represents a conjugated port.
	//
	bool conjugate_;

	//
	// Flag to indicate if messages check by this instance should be logged.
	// This shouldn't be mutable, but all our access to contract checkers is
	// const and we need to be able to change this flag...
	//
	mutable bool isLogged_;

	//
	// Need to synch access to logged flag.
	//
	mutable SimpleCriticalSection cs_;
};

}
